using System;

namespace CSharpPro._1028;

public class User
{
    private readonly IUserService _userService;

    public User(IUserService userService)
    {
        _userService = userService;
    }

    // 显示主菜单
    public void Show()
    {
        while (true)
        {
            Console.WriteLine("主菜单：");
            Console.WriteLine("1. 登录");
            Console.WriteLine("2. 注册");
            Console.WriteLine("3. 退出");
            Console.Write("请输入选项（1-3）：");

            string choice = Console.ReadLine();

            if (choice == "1")
            {
                Console.WriteLine("===== 登录 =====");
                Console.Write("用户名：");
                string username = Console.ReadLine();
                Console.Write("密码：");
                string password = Console.ReadLine();
                _userService.Login(username, password);
            }
            else if (choice == "2")
            {
                Console.WriteLine("===== 注册 =====");
                Console.Write("用户名：");
                string username = Console.ReadLine();
                Console.Write("密码：");
                string password = Console.ReadLine();
                Console.Write("确认密码：");
                string confirmPassword = Console.ReadLine();
                _userService.Regist(username, password, confirmPassword);
            }
            else if (choice == "3")
            {
                Console.WriteLine("退出程序。");
                break;
            }
            else
            {
                Console.WriteLine("输入错误，请重新输入。");
            }
        }
    }
}